package com.jwell.panprovider.ui.fragment.waybillinfo


import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

import com.jwell.panprovider.R
import com.jwell.panprovider.entity.WaybillInfoBean
import com.jwell.panprovider.tools.StringUtils
import com.jwell.panprovider.ui.activity.WaybillInfoActivity
import kotlinx.android.synthetic.main.fragment_check_info.*


/**
 * A simple [Fragment] subclass.
 * 进场验收信息
 */
class CheckInfoFragment constructor() : Fragment() {


    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,
                              savedInstanceState: Bundle?): View? {
        // Inflate the layout for this fragment
        var view = inflater!!.inflate(R.layout.fragment_check_info, container, false)
        initData()
        return view
    }

    private fun initData() {
        var activity = activity as WaybillInfoActivity
        activity.setListener1(object : WaybillInfoActivity.DataListener1 {
            override fun setData(data: WaybillInfoBean) {
                data.let {
                    text_rankTime.text = StringUtils.getInstance()
                            .setModal(StringUtils.TIME_TYPE_3)
                            .regularization(it.seqTime, "T", " ")
                    text_rankNum.text = it.seqId ?: ""
                    text_inGateNum.text = it.gateControlInDescr ?: ""
                    text_inGateTime.text = StringUtils.getInstance()
                            .setModal(StringUtils.TIME_TYPE_3)
                            .regularization(it.gateControlOutTime, "T", " ")
                    text_outGateNum.text = it.gateControlInDescr ?: ""
                    text_outGateTime.text = StringUtils.getInstance()
                            .setModal(StringUtils.TIME_TYPE_3)
                            .regularization(it.factGateControlOutTime, "T", " ")
                    //重车计量信息
                    it.heavyMetering?.let {
                        ll_2.visibility = View.VISIBLE
                        text_grossWt.text = it.grosS_WT ?: ""
                        text_measureTime.text = StringUtils.getInstance()
                                .setModal(StringUtils.TIME_TYPE_3)
                                .regularization(it.heavY_CAR_MEASURE_TIME, "T", " ")
                        text_transport_goods_num.text = it.waybilL_NO ?: ""
                        text_pound_num.text = it.weighT_NO ?: ""
                        text_measure_address.text = it.heavY_CAR_MEASURE_PLACE_DESCR ?: ""
                        text_measure_person.text = it.heavY_CAR_MEASURE_BY_DESCR ?: ""
                        text_pizhong_type.text = it.tarE_MODE ?: ""
                    }
                    //取样信息
                    it.samling?.let {
                        ll_3.visibility = View.VISIBLE
                        text_sampling_address.text = it.samplinG_PLACE ?: ""
                        text_sampling_person.text = it.samplinG_BY ?: ""
                        text_sampling_time.text = StringUtils.getInstance()
                                .setModal(StringUtils.TIME_TYPE_3)
                                .regularization(it.samplinG_REGISTRATION_DATE, "T", " ")
                        //详细取样点
                        text_detail_take_samples_place.text = it.particulaR_SAMPLING_PLACE ?: ""
                        //水分扣量值
                        text_shuifenkouliangzhi.text = it.wateR_DEDUCT_VALUE.toString()
                        //杂质扣量值
                        text_zazhikouliangzhi.text = it.impuritY_DEDUCT_VALUE.toString()
                        //其他扣量值
                        text_other_detain.text = it.otheR_DEDUCT_VALUE.toString()
                    }
                    //卸料信息
                    it.unloading?.let {
                        ll_4.visibility = View.VISIBLE
                        text_xieche_address.text = it.unloaD_CAR_PLACE_DESCR ?: ""
                        text_xieche_addrees_code.text = it.unloaD_CAR_PLACE ?: ""
                        text_xieche_sure_person.text = it.unloaD_CAR_PLACE_BY_DESCR ?: ""
                        text_xieche_time.text = StringUtils.getInstance()
                                .setModal(StringUtils.TIME_TYPE_3)
                                .regularization(it.facT_UNLOAD_CAR_TIME, "T", " ")
                    }
                    //空车计量信息
                    it.emptyCarMeasurement?.let {
                        ll_5.visibility = View.VISIBLE
                        text_neT_WT.text = it.neT_WT.toString() + "吨"
                        text_tarE_WT.text = it.tarE_WT.toString() + "吨"
                        text_measureTime1.text = StringUtils.getInstance()
                                .setModal(StringUtils.TIME_TYPE_3)
                                .regularization(it.emptY_CAR_MEASURE_TIME, "T", " ")
                        text_pound_num1.text = it.weighT_NO ?: ""
                        text_transport_goods_num1.text = it.waybilL_NO ?: ""
                        text_measure_address1.text = it.emptY_CAR_MEASURE_PLACE_DESCR ?: ""
                        text_measure_person1.text = it.emptY_CAR_MEASURE_BY_DESCR ?: ""
                    }
                }
            }
        })

    }
}
